<{include file="header.html"}>
<script type="text/javascript">
function submitFilter()
{document.frm_filter.submit();
	return true;
	
}
function updateStatus(id_product, value) {
	var args = Array();
	args.push(id_product);
	args.push(value);

	var ajaxRes = callFunction('Product::updateStatus', args);

	// if update success, change status
	if (ajaxRes) {
		if (value == 1) {
			$('.OBJ_' + id_product).find('.disable_button').hide();
			$('.OBJ_' + id_product).find('.enable_button').show();
		} else {
			$('.OBJ_' + id_product).find('.disable_button').show();
			$('.OBJ_' + id_product).find('.enable_button').hide();
		}
	}
}
</script>
	<div class="one_third">

			<div class="box_tool">
				<div class="box_head"><{$smarty.const._LB_TOOLBOX|utf8_escape_html}></div>
				<div class="box_content">
					<a href="<{$smarty.const.APPLICATION_URL}>/product/form/">
						<{$smarty.const._LB_CREATE_PRODUCT|utf8_escape_html}>
					</a>
				</div>
			</div>
			<div class="spacer"></div>
			<div class="box_tool">
				<div class="box_head"><{$smarty.const._LB_FILTER|utf8_escape_html}></div>
				<div class="box_content">
					<form id='frm_filter' name='frm_filter' method="get" action="">
					<div class="content" id="filter_panel" style="padding-bottom:0px;">
						<table class="">
							<tr>
								<td width="20%"><{$smarty.const._LB_NAME|utf8_escape_html}>&nbsp;:&nbsp;</td>
								<td><input style="width:98%;" name="NAME" id="NAME" type="text" size="30" value="<{$filter.NAME|utf8_escape_html}>" /></td>
							</tr>
							<tr>
								<td><{$smarty.const._LB_CATEGORY|utf8_escape_html}>&nbsp;:&nbsp;</td>
								<td>
									<select name="ID_CATEGORY" id="ID_CATEGORY">
										<option value="0"><{$smarty.const._LB_ALL|utf8_escape_html}></option>
										<option value="-1" <{if $filter.ID_CATEGORY == -1}>selected<{/if}>>-- Root --</option>
										<{include file="category_tree_select_parent.html" cats=$cats padding=0 id_current=0 id_parent=$filter.ID_CATEGORY}>
									</select>
								</td>
							</tr>
							<tr>
								<td><{$smarty.const._LB_STATUS|utf8_escape_html}>&nbsp;:&nbsp;</td>
								<td>
									<select name="STATUS">
										<option value="0"><{$smarty.const._LB_ALL|utf8_escape_html}></option>
										<option value="1" <{if $filter.STATUS == 1}>selected<{/if}>><{$smarty.const._LB_ENABLED|utf8_escape_html}></option>
										<option value="2" <{if $filter.STATUS == 2}>selected<{/if}>><{$smarty.const._LB_DISABLED|utf8_escape_html}></option>
									</select>
								</td>
							</tr>
						</table>
					</div>
					<div class="submit" align="right" style="padding-top:10px;">
						<a class="tribullet" href="#" onclick="submitFilter()"><{$smarty.const._LB_SEARCH|utf8_escape_html}></a>
					</div>
					</form>
				</div>
			</div>
	</div>

	<div class="two_third">
		<div class="box_two_third">
		<div class="box_head"><{$smarty.const._LB_PRODUCT_MANAGEMENT|utf8_escape_html}></div>
		<div class="box_content" style="padding-left: 11px;">
			<div class="list" style="padding-top: 5px;">
				<{if $product->N > 0 }>
					<{while $product->fetch()}>
						<div class="object OBJ_<{$product->ID}>">
						<div class="head">
							<span class="right">
								<a class="disable_button" <{if $product->DISABLED == 1}>style="display:none;"<{/if}>href="javascript:updateStatus(<{$product->ID}>, 1);">
									<img class="small" src="<{$smarty.const.APPLICATION_URL}>/images/<{$smarty.const.IMAGE_NAME_CANCEL_SMALL}>" alt="" title="<{$smarty.const._LB_DISABLE|utf8_escape_html}>" />
								</a>
								<a class="enable_button" <{if $product->DISABLED == 0}>style="display:none;"<{/if}>href="javascript:updateStatus(<{$product->ID}>, 0);">
									<img class="small" src="<{$smarty.const.APPLICATION_URL}>/images/<{$smarty.const.IMAGE_NAME_DONE_SMALL}>" alt="" title="<{$smarty.const._LB_ENABLE|utf8_escape_html}>" />
								</a>
								<a href="<{$smarty.const.APPLICATION_URL}>/product/form/?id=<{$product->ID}>">
									<img class="small" src="<{$smarty.const.APPLICATION_URL}>/images/<{$smarty.const.IMAGE_NAME_EDIT_SMALL}>" alt="" title="<{$smarty.const._LB_EDIT|utf8_escape_html}>" />
								</a>
								<a onclick="return confirm('<{$smarty.const._MSG_PRODUCT_DELETE_CONFIRM|utf8_escape_html}>')"  href="<{$smarty.const.APPLICATION_URL}>/product/delete/?id=<{$product->ID}>">
									<img class="small" src="<{$smarty.const.APPLICATION_URL}>/images/<{$smarty.const.IMAGE_NAME_DELETE_SMALL}>" alt=""  title="<{$smarty.const._LB_DELETE|utf8_escape_html}>" />
								</a>
							</span>
							<div style="margin-left: <{$margin}>px">
								<img class="small" src="<{$smarty.const.APPLICATION_URL}>/images/<{$smarty.const.IMAGE_NAME_REGION_SMALL}>" alt="" /> <{$product->NAME|utf8_escape_html}>
							</div>
							<div class="content">
								<img class="left" style="padding-top:5px;padding-right: 10px;" width ="100" src="<{$smarty.const.PRODUCT_IMAGE_URL}>/thumb<{$product->IMAGE}>"></a>
								<p><{$product->SHORT_DESCRIPTION}></p>
								<div style="clear: both;"></div>
							</div>
						</div>
						</div>
					<{/while}>
				<{else}>
					<{$smarty.const._LB_NO_ITEM|utf8_escape_html}>
				<{/if}>
			</div>
		</div>
		<div class="pagination">
            <{$pager->display()}>
        </div>
	</div>		
	</div>

<{include file="footer.html"}>